﻿@using System.Web.Mvc.Html
@using Dogshow.Model
@model Pas

@{
    ViewBag.Title = "Dogshow - Psi";
}
<script src="@Url.Content("~/Scripts/imageupload.js")" type="text/javascript"></script>
<script>
    var idPsa = null;
    var idVlasnika = null;
    
    function onBeginUcitajPsa(s, e) {
        e.customArgs["id"] = idPsa;
        idPsa = null;
        ponistiSliku();
    }
    
    function onPasChanged(s, e) {
        s.GetRowValues(s.GetFocusedRowIndex(), "Id", function (value) {
            idPsa = value;
            if (!cbpPas.IsCallback && idPsa != null) {
                cbpPas.PerformCallback();    
            }
        });
    }
    
    function onNoviUnos(s, e) {
        resetValidation();
        $("#Id").val("0");
        ponistiSliku();
    }
    
    function ponistiSliku() {
        $("#ImagePreview").attr("src", "/");
        $("#SlikaPsa").removeAttr("value");
    }

    function resetValidation() {
        ASPxClientEdit.ClearEditorsInContainer();
    }

    function onSuccessDodajKinologa(result) {
        if (result["Success"]) {
            UnosKinologaPopup.Hide();
            var item = result["Item"];
            idVlasnika = item.Id;
            //IdVlasnika.PerformCallback();
            IdVlasnika.AddItem([item.ImeIPrezime, item.Mesto.Naziv], item.Id);
            IdVlasnika.SetValue(item.Id);
        }
    }

    function openPopup() {
        ImeIPrezime.SetText(null);
        Adresa.SetText(null);
        Telefon.SetText(null);
        IdMesta.SetText(null);
        UnosKinologaPopup.Show();
        ImeIPrezime.Focus();
    }

    
    
</script>

<div style="float: left; width:300px;">
    @Html.Partial("_PsiGridView", (IEnumerable<Pas>)ViewBag.Psi)
</div>
<div style="margin-left: 310px;">
    @Html.Partial("_PasCallbackPanel", Model)
</div>
